﻿Public Class FrmThumb
	'Public Video As Video
    Dim Second As Integer = 1

    Private Sub FrmThumb_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If Not PictureBox1.BackgroundImage Is Nothing Then
            PictureBox1.BackgroundImage.Dispose()
            PictureBox1.BackgroundImage = Nothing
        End If
    End Sub

    Private Sub FrmThumb_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        PictureBox1.BackgroundImageLayout = ImageLayout.Stretch
        Extract()
    End Sub

    Sub Extract()
		'      Dim Time As String = "00:" & Format(Second \ 60, "00") & ":" & Format(Second Mod 60, "00")
		'Shell("""" & My.Settings.ffmpeg & """ -i " & Video.Source & " -y -r 1/5 -ss " & Second & " -t 00:00:01 -f image2 """ & My.Computer.FileSystem.SpecialDirectories.Temp & "\" & Video.Title & "%01d.png""", AppWinStyle.Hide, True)
		'      Dim Stream As New System.IO.FileStream(My.Computer.FileSystem.SpecialDirectories.Temp & "\" & Video.Title & "1.png", IO.FileMode.Open)
		'      PictureBox1.BackgroundImage = Image.FromStream(Stream)
		'      Stream.Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Second -= 1
        Extract()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Second += 1
        Extract()
    End Sub

End Class